---
id: 656680b0fc79f2c38a34d90e
title: Passo 10
challengeType: 20
dashedName: step-10
---

# --description--

Now it's time to sort and merge the lists (`left_part` and `right_part`) into the original `array`.

You can do this by comparing elements on both lists, and merging the smaller element to the main list. You are going to do this comparison for all the indexes in `left_part` and `right_part`.

Create three variables: `left_array_index`, `right_array_index`, and `sorted_index` and set their values to `0`. These variables will help you keep track of each index during the sorting process.

# --hints--

You should have a variable named `left_array_index` inside your `merge_sort` function

```js
({
  test: () => {
    const transformedCode = code.replace(/\r/g, "");
    const merge_sort = __helpers.python.getDef("\n" + transformedCode, "merge_sort");
    const { function_body } = merge_sort;

    assert.match(function_body, /left_array_index\s*(?!=)/);
  }
})
```

The value of `left_array_index` should be 0

```js
({
  test: () => {
    const transformedCode = code.replace(/\r/g, "");
    const merge_sort = __helpers.python.getDef("\n" + transformedCode, "merge_sort");
    const { function_body } = merge_sort;

    assert.match(function_body, /left_array_index\s*=\s*0/);
  }
})
```

You should have a variable named `right_array_index` inside your `merge_sort` function

```js
({
  test: () => {
    const transformedCode = code.replace(/\r/g, "");
    const merge_sort = __helpers.python.getDef("\n" + transformedCode, "merge_sort");
    const { function_body } = merge_sort;

    assert.match(function_body, /right_array_index\s*(?!=)/);
  }
})
```

The value of `right_array_index` should be 0

```js
({
  test: () => {
    const transformedCode = code.replace(/\r/g, "");
    const merge_sort = __helpers.python.getDef("\n" + transformedCode, "merge_sort");
    const { function_body } = merge_sort;

    assert.match(function_body, /right_array_index\s*=\s*0/);
  }
})

```

You should have a variable named `sorted_index` inside your `merge_sort` function

```js
({
  test: () => {
    const transformedCode = code.replace(/\r/g, "");
    const merge_sort = __helpers.python.getDef("\n" + transformedCode, "merge_sort");
    const { function_body } = merge_sort;

    assert.match(function_body, /sorted_index\s*(?!=)/);
  }
})
```

The value of `sorted_index` should be 0

```js
({
  test: () => {
    const transformedCode = code.replace(/\r/g, "");
    const merge_sort = __helpers.python.getDef("\n" + transformedCode, "merge_sort");
    const { function_body } = merge_sort;

    assert.match(function_body, /sorted_index\s*=\s*0/);
  }
})
```

# --seed--

## --seed-contents--

```py
def merge_sort(array):

    middle_point = len(array) // 2
    left_part = array[:middle_point]
    right_part = array[middle_point:]
    merge_sort(left_part)
    merge_sort(right_part)

--fcc-editable-region--

--fcc-editable-region--
```
